package me.magicall.db.sql.condition;

import me.magicall.db.sql.Operatable;
import me.magicall.db.sql.TwoElementOperation;
import me.magicall.db.sql.expression.Expression;

/**
 * 一个条件.
 * 一个条件即是一个二元表达式.如X=Y , X>Y , X like Y ,X in(Y),X between Y(Y1 and Y2的表达式)
 * 
 * @author MaGiCalL
 */
public class OneCondition extends TwoElementOperation<Expression<?>, OneConditionOperator>//
		implements Operatable {

	public OneCondition() {
		super();
	}

	public OneCondition(final Expression<?> firstArg, final OneConditionOperator operator, final Expression<?> secondArg) {
		super(firstArg, operator, secondArg);
	}

	//======================================
	public static OneCondition le(final Expression<?> firstExpression, final Expression<?> secondExpression) {
		return new NegativableCondition(firstExpression, OneConditionOperator.LE, secondExpression);
	}

	public static OneCondition ge(final Expression<?> firstExpression, final Expression<?> secondExpression) {
		return new NegativableCondition(firstExpression, OneConditionOperator.GE, secondExpression);
	}

	public static OneCondition lt(final Expression<?> firstExpression, final Expression<?> secondExpression) {
		return new NegativableCondition(firstExpression, OneConditionOperator.LT, secondExpression);
	}

	public static OneCondition gt(final Expression<?> firstExpression, final Expression<?> secondExpression) {
		return new NegativableCondition(firstExpression, OneConditionOperator.GT, secondExpression);
	}

	public static OneCondition equalsCondition(final Expression<?> firstExpression, final Expression<?> secondExpression) {
		return new NegativableCondition(firstExpression, OneConditionOperator.EQUALS, secondExpression);
	}

}
